﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using RegisterationCommon.Common;
using RegisterationCommon.Contrast;
using System.Data;
using RegisterationCommon.Education;

namespace RegisterationSystem.Space_Education
{
    public partial class studentinfoadd_contrast : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                switch (Request.Form["action"])
                {
                    case "del":
                        DelStus();
                        break;
                }
                if (string.IsNullOrEmpty(Request.Form["action"]))
                {
                    this.Birthday.Value = DateTime.Now.ToString("yyyy-MM-dd");
                }
            }
        }
        protected void btnadd_Click(object sender, EventArgs e)
        {
            ContrastInfo ctdt = new ContrastInfo();
            ctdt.CtName = this.txtname.Value.Trim();
            ctdt.CtBirthday = Convert.ToDateTime(this.Birthday.Value);
            ctdt.CtSex = this.ddlsex.SelectedValue == "0" ? false : true; ;
            ctdt.CtAddress = this.txtPermanentAddress.Value.Trim();
            ctdt.CtGuardName = this.txtFirstGuardianName.Value.Trim();
            ctdt.CtGuardRelation = this.txtFirstRelationship.Value.Trim();
            if (ctdt.AddNewStudentInfoCt())
            {
                Message.Send(10055);
            }

        }
        //删除学生
        void DelStus()
        {
            //获取修改ID和学校ID
            string idlist = Request.Form["id"];
            string[] ids = idlist.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            for (int i = 0; i < ids.Length; i++)
            {
                if (!string.IsNullOrEmpty(ids[i].Trim()))
                {
                    DBAction.Delete("ContrastInfo", "ID=" + ids[i].Trim());
                }
            }
        }

    }
}